import React from 'react'
import * as PropTypes from 'prop-types';
import ReactEcharts from 'echarts-for-react';
import echartsConfig from 'utils/echartsConfig'

class Common2 extends React.Component {
    static defaultProps = {
        dataSource: {},
        columns: {},
    }
    // {
    //     time: ["2019-01", "2019-02", "2019-03", "2019-04", "2019-05", "2019-06", "2019-07", "2019-08", "2019-09", "2019-10", "2019-11", "2019-12"],
    //     data: [
    //         {name: "抄表块数", field: "sell", type: "bar", data: []},
    //         {name: "未抄表块数", field: "subtract", type: "bar", data: []},
    //         {name: "水表抄件率", field: "radio", type: "line", yAxisIndex: 1, data: []
    //     },
    // }
    render(){
        const { dataSource, columns, color, other, style = {height: '265px'} } = this.props;
        const { time: xAxisData, data: seriesData } = dataSource;
        const { yAxis } = columns;
        const Data = {
            xAxisData,
            yAxis,
            seriesData,
        }
        const Options = echartsConfig.commonEChartsOptions(Data, color, other)
        return (
            <ReactEcharts
                option={Options}
                notMerge={true}
                lazyUpdate={true}
                style={style}
            />
        )
    }
}

Common2.propTypes = {
    dataSource: PropTypes.object,
    columns: PropTypes.object,
}
export default Common2
